package view
{
	import flash.events.Event;
	
	import model.DataProxy;
	import model.ViewProxy;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class HeaderViewMediator extends Mediator implements IMediator
	{
		public static const NAME:String					= "HeaderViewMediator";
		
		private var headerView:HeaderView;
		
		public function HeaderViewMediator( viewComponent:Object = null )
		{
			super( NAME, viewComponent );
		}
		
		override public function onRegister():void
		{
			headerView = new HeaderView();
			headerView.addEventListener( HeaderView.CLICKED, headerViewClickedHandler );
			headerView.init( viewProxy.vo );
			
			viewProxy.vo.headerView = headerView;
			
			viewComponent.addChild( headerView );
		}
		
		private function headerViewClickedHandler( e:Event ):void
		{
			sendNotification( MenuView.UPDATE, { index:0 } );
		}
		
		private function get dataProxy():DataProxy
		{
			return facade.retrieveProxy( DataProxy.NAME) as DataProxy;
		}
		
		private function get viewProxy():ViewProxy
		{
			return facade.retrieveProxy( ViewProxy.NAME	) as ViewProxy;
		}
	}
}